package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper mapper;
    @Override
    public void add(EmployeeBean emBean, int deptId) {
        mapper.add(emBean,deptId);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, int deptId, int money) {
        mapper.update(id,deptId,money);
    }

    @Override
    public EmployeeBean findById(int id) {
        return mapper.findById(id);
    }

    @Override
    public EmployeeBean findId(int id) {
        return mapper.findId(id);
    }

    @Override
    public PageInfo<EmployeeBean> findByItem(int pageNO, String name, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNO,3);
        PageInfo<EmployeeBean> pageInfo = PageInfo.of(mapper.findByItem(name,startDate,endDate));
        return pageInfo;
    }
}
